using System;
using System.IO;
using EPiServer.Common;
using EPiServer.Common.Security;
using EPiServer.Community.Webmail;

namespace EPiAbstractions.Community.Webmail
{
    public interface IWebmailHandlerFacade
    {
        MailAccount AddMailAccount(MailAccount mailAccount);

        void UpdateMailAccount(MailAccount mailAccount);

        void RemoveMailAccount(MailAccount mailAccount);

        MailAccount GetMailAccount(Int32 id);

        MailAccountCollection GetMailAccounts(IUser user);

        MailAccountCollection GetMailAccounts(IUser user, MailServer mailServer);

        MailServer AddMailServer(MailServer mailServer);

        void UpdateMailServer(MailServer mailServer);

        void RemoveMailServer(MailServer mailServer);

        MailServer GetMailServer(Int32 id);

        MailServer GetMailServer(String name);

        MailServerCollection GetMailServers();

        void SoftRemoveMailAccount(InternalMailAccount mailAccount);

        void SoftRestoreMailAccount(InternalMailAccount mailAccount);

        void SetQuota(InternalMailAccount mailAccount, Int32 quota);

        void UpdatePassword(InternalMailAccount mailAccount);

        Mailbox GetRootMailbox(MailAccount mailAccount);

        String GetHTMLBody(ServerMessage message);

        String GetTextBody(ServerMessage message);

        AttachmentCollection GetAttachments(ServerMessage message);

        Stream GetAttachmentStream(ServerAttachment attachment);

        MailAccountStatus GetMailAccountStatus(InternalMailAccount mailAccount);

        MailAccountStatus GetMailAccountStatus(IUser user, InternalMailServer mailServer);

        InternalMailAccount GetInternalMailAccount(IUser user, InternalMailServer mailServer);

        Mailbox AddMailbox(String name, Mailbox parent);

        void RemoveMailbox(Mailbox mailbox);

        ServerMessage GetMessage(UInt32 messageId, Mailbox mailbox);

        MessageCollection GetMessages(Mailbox mailbox, Int32 page, Int32 pageSize, MessageSortOrder sortOrder);

        MessageCollection GetMessages(Mailbox mailbox, Int32 page, Int32 messagesPerPage, out Int32 totalItems, MessageSortOrder sortOrder);

        void MoveMessage(ServerMessage message, Mailbox destination);

        void RemoveMessage(ServerMessage message);

        MessageCollection Search(String needle, Mailbox haystack, Int32 page, Int32 pageSize, MessageSortOrder sortOrder);

        MessageCollection Search(String needle, Mailbox haystack, Int32 page, Int32 pageSize, out Int32 totalItems,
                                 MessageSortOrder sortOrder);

        void AddMessage(Mailbox mailbox, LocalMessage message);

        void SendMessage(LocalMessage message, MailAccount mailAccount);

        void SendMessage(LocalMessage message, Boolean removeAttachedFiles, MailAccount mailAccount);

        QuotaStats GetQuotaStats(MailAccount mailAccount);

        void SendMessage(LocalMessage message, Mailbox mailbox);

        void SendMessage(LocalMessage message, Mailbox mailbox, Boolean removeAttachedFiles);

        void UpdateMailAccountDomain(InternalMailAccount mailAccount);

        Domain AddDomain(Domain domain);

        DomainCollection GetDomains();

        Domain GetDomain(Int32 id);

        Domain GetDomainByDomainName(String domainName);

        Domain GetDomainByMailAccount(InternalMailAccount mailAccount);

        void UpdateDomain(Domain domain);

        void RemoveDomain(Domain domain);

        void UpdateServerMessage(ServerMessage message);

        event EPiServerCommonEventHandler MailAccountAdded;

        event EPiServerCommonEventHandler MailAccountRemoved;

        event EPiServerCommonEventHandler MailboxAdded;

        event EPiServerCommonEventHandler MailboxRemoved;

        event EPiServerCommonEventHandler MessageAdded;

        event EPiServerCommonEventHandler MessageSent;

        event EPiServerCommonEventHandler MessageRemoved;
    }
}